Share more code between tests imported from WebKit. (#3853) Also move defineNewCustomElement (renamed to define_new_custom_element) and assert_attribute_log_entry from reactions.js to custom-elements-helpers.js so that we can reuse them in the newly added tests. Finally, rename log() function on returned by define_new_custom_element to takeLog() and renamed log() on the object returned by takeLog() to last() to make their semantics clear.
diff --git a/custom-elements/disconnected-callbacks.html b/custom-elements/disconnected-callbacks.html index 97ea67a..7f5a4d0 100644 --- a/custom-elements/disconnected-callbacks.html +++ b/custom-elements/disconnected-callbacks.html
@@ -7,7 +7,7 @@ <link rel="help" href="https://w3c.github.io/webcomponents/spec/custom/#dfn-connected-callback"> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> -<script src="resources/document-types.js"></script> +<script src="./resources/custom-elements-helpers.js"></script> </head> <body> <div id="log"></div> @@ -20,7 +20,7 @@ } customElements.define('my-custom-element', MyCustomElement); -DocumentTypes.forEach(function (entry) { +document_types().forEach(function (entry) { var documentName = entry.name; var getDocument = entry.create; @@ -32,7 +32,7 @@ doc.documentElement.removeChild(instance); assert_array_equals(calls, ['disconnected', instance]); }); - }, 'Removing a custom element from a ' + documentName + ' must enqueue and invoke disconnectedCallback'); + }, 'Removing a custom element from ' + documentName + ' must enqueue and invoke disconnectedCallback'); promise_test(function () { return getDocument().then(function (doc) { @@ -44,7 +44,7 @@ doc.documentElement.removeChild(parent); assert_array_equals(calls, ['disconnected', instance]); }); - }, 'Removing an ancestor of custom element from a ' + documentName + ' must enqueue and invoke disconnectedCallback'); + }, 'Removing an ancestor of custom element from ' + documentName + ' must enqueue and invoke disconnectedCallback'); promise_test(function () { return getDocument().then(function (doc) { @@ -58,7 +58,7 @@ shadowRoot.removeChild(instance); assert_array_equals(calls, ['disconnected', instance]); }); - }, 'Removing a custom element from a shadow tree in a ' + documentName + ' must enqueue and invoke disconnectedCallback'); + }, 'Removing a custom element from a shadow tree in ' + documentName + ' must enqueue and invoke disconnectedCallback'); promise_test(function () { return getDocument().then(function (doc) { @@ -85,7 +85,7 @@ shadowRoot.removeChild(instance); assert_array_equals(calls, []); }); - }, 'Removing a custom element from a detached shadow tree that belongs to a ' + documentName + ' must not enqueue and invoke disconnectedCallback'); + }, 'Removing a custom element from a detached shadow tree that belongs to ' + documentName + ' must not enqueue and invoke disconnectedCallback'); }); </script>